package com.example.lncd.ui.elderly;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.lncd.R;
import com.example.lncd.model.User;

import java.util.List;

public class RelatedFamilyAdapter extends RecyclerView.Adapter<RelatedFamilyAdapter.ViewHolder> {

    private List<User> families;

    public RelatedFamilyAdapter(List<User> families) {
        this.families = families;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_related_family, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        User family = families.get(position);
        holder.tvUsername.setText(family.getUsername());
        holder.tvPhone.setText(family.getPhone());
    }

    @Override
    public int getItemCount() {
        return families.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvUsername, tvPhone;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvUsername = itemView.findViewById(R.id.tvUsername);
            tvPhone = itemView.findViewById(R.id.tvPhone);
        }
    }
} 